﻿/*
 * Copyright 2014 Francois Karman
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using Microsoft.Build.Framework;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Quartz.WebManager.BuildExt
{
    /// <summary>
    /// Tests the <see cref="MergeXmlDocTask"/> class.
    /// </summary>
    [TestClass]
    public class MergeXmlDocTaskTest
    {
        /// <summary>
        /// Tests the <see cref="MergeXmlDocTask.Execute"/> method.
        /// </summary>
        [TestMethod]
        public void Execute()
        {
            MergeXmlDocTask instance = new MergeXmlDocTask();

            instance.OutputFile = "output.xml";
            instance.InputFiles = new ITaskItem[]
            {
                new TaskItem("MergeXmlDocTaskTest-input1.xml"),
                new TaskItem("MergeXmlDocTaskTest-input2.xml"),
            };

            Assert.IsTrue(instance.Execute());
            FileAssert.AreEqual("MergeXmlDocTaskTest-expected.xml", "output.xml");
        }

        /// <summary>
        /// Implements the <see cref="ITaskItem"/> interface for test purpose.
        /// </summary>
        private class TaskItem : ITaskItem
        {
            public TaskItem(string itemSpec)
            {
                this.ItemSpec = itemSpec;
            }

            public string ItemSpec { get; set; }

            public int MetadataCount
            {
                get { throw new NotImplementedException(); }
            }

            public ICollection MetadataNames
            {
                get { throw new NotImplementedException(); }
            }

            public IDictionary CloneCustomMetadata()
            {
                throw new NotImplementedException();
            }

            public void CopyMetadataTo(ITaskItem destinationItem)
            {
                throw new NotImplementedException();
            }

            public string GetMetadata(string metadataName)
            {
                throw new NotImplementedException();
            }

            public void RemoveMetadata(string metadataName)
            {
                throw new NotImplementedException();
            }

            public void SetMetadata(string metadataName, string metadataValue)
            {
                throw new NotImplementedException();
            }
        }
    }
}
